using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Hostal.Bussines.Entities;

namespace Hostal.Bussines.Repository.Mapping
{
    public class ReservaMap : EntityTypeConfiguration<Reserva>
    {
        public ReservaMap()
        {
            // Primary Key
            this.HasKey(t => t.IdReserva);

            // Properties
            // Table & Column Mappings
            this.ToTable("Reservas");
            this.Property(t => t.IdReserva).HasColumnName("IdReserva");
            this.Property(t => t.IdHabitacion).HasColumnName("IdHabitacion");
            this.Property(t => t.Huesped_Id).HasColumnName("Huesped_Id");
            this.Property(t => t.NHabitaciones).HasColumnName("NHabitaciones");
            this.Property(t => t.Fecha).HasColumnName("Fecha");
            this.Property(t => t.CheckIn).HasColumnName("CheckIn");
            this.Property(t => t.CheckOut).HasColumnName("CheckOut");
            this.Property(t => t.PeriodoEstadia).HasColumnName("PeriodoEstadia");
            this.Property(t => t.Total).HasColumnName("Total");

            // Relationships
            this.HasRequired(t => t.Huesped)
                .WithMany(t => t.Reservas)
                .HasForeignKey(d => d.Huesped_Id);
            this.HasRequired(t => t.TipoHabitacione)
                .WithMany(t => t.Reservas)
                .HasForeignKey(d => d.IdHabitacion);

        }
    }
}
